function JQuery() {
	this.ajax = function(options) {
		if (typeof (options) != "object"){
			throw new Error("arguments options is not a valid object");
		}
		var dataType = options.dataType ? options.dataType : "text";
		var type = options.type ? options.type : "get";
		var data = options.data ;
		if(data){
			var empty=true;
			for(var key in data){
				empty=false;break;
			}
			if(empty){
				data = null;
			}
		}
		var async = options.async==undefined ? true: options.async;
		var url = options.url;
		var user = options.user;
		var password = options.password;
		var success=options.success;
		var error=options.error;
		var xhr = getXmlHttpRequest();
		if(!xhr){
			var errorMsg=" ajax is not supported by your browser! \nyour browser is: \t"+navigator.appName+"\t "+navigator.appVersion;
			throw new Error(errorMsg);
		}
		    xhr.onreadystatechange =callBack;
		function callBack(_data,status) {
			try{				
				if (this.readyState == 4 && this.status == 200) {
						switch(dataType){
							case "text":_data=this.responseText;break;
							case "html":_data=this.responseHTML;break;
							case "xml":_data=this.responseXML;break;
							case "script":_data=eval(this.responseText);break;
							case "json":_data=eval("("+this.responseText+")");break;
							default:_data=this.responseText;break;
						}
						if(typeof(success)=="function"){
							return success(_data,this.status);						
						}
				}
			}catch(e){
				if(typeof(error)=="function"){
					return error(this, this.status,e);	
				}
				throw e;
			}							
		}				
		xhr.open(type,url, async, user, password);
		xhr.send(data);		
	}
}
function getXmlHttpRequest() {
	var xhr = null;
	try {
		if (window.XMLHttpRequest) {
			xhr = new XMLHttpRequest();
			if (xhr.overrideMimeType) {
				xhr.overrideMimeType('text/xml');
			}
		} else if (window.ActiveXObject) {
			for ( var i = 5; i; i--) {
				try {
					if (i == 2) {
						xhr = new ActiveXObject("Microsoft.XMLHTTP");
					} else {
						xhr = new ActiveXObject("Msxml2.XMLHTTP." + i + ".0");
						xhr.setRequestHeader("Content-Type", "text/xml");
						xhr.setRequestHeader("Charset", "UTF-8");
						break;
					}
				} catch (e) {
					xhr = false;
				}
			}
		}
	} catch (e) {
		xhr = false;
	}	
	return xhr;
}
(function(window) {	
	window.jQuery = window.$ = new JQuery();
})(window);
/*
目前我们可能得到的系统异常主要包含以下6种:
EvalError: raised when an error occurs executing code in eval()
RangeError: raised when a numeric variable or parameter is outside of its valid range
ReferenceError: raised when de-referencing an invalid reference
SyntaxError: raised when a syntax error occurs while parsing code in eval()
TypeError: raised when a variable or parameter is not a valid type
URIError: raised when encodeURI() or decodeURI() are passed invalid parameters
上面的六种异常对象都继承自Error对象。他们都支持以下两种构造方法:
new Error();
new Error( " 异常信息 " );

Error具有下面一些主要属性：
description: 错误描述 (仅IE可用).
fileName: 出错的文件名 (仅Mozilla可用).
lineNumber: 出错的行数 (仅Mozilla可用).
message: 错误信息 (在IE下同description)
name: 错误类型.
number: 错误代码 (仅IE可用).
stack: 像Java中的Stack Trace一样的错误堆栈信息 (仅Mozilla可用).


 
*/